﻿using GalaSoft.MvvmLight;

namespace WpfApplicationTest
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// You can also use Blend to data bind with the tool's support.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase
    {
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real": Connect to service, etc...
            ////}
            MaxValue = 100;
            MaxAmps = 24;
            Alarm = 0.7;
            Label = "Speed";
            MajorTicks = MaxValue/10;
            GaugeHeight = 300;
        }

        
        private int _minValue;
        private int _maxValue;
        private int _maxAmps;
        private double _speed;
        private double _alarm;
        private string _label;
        private int _majorTicks;
        private double _height;
        public int MinValue
        {
            get { return _minValue; }
            set
            {
                _minValue = value;
                RaisePropertyChanged("MinValue");
            }
        }

        public int MaxValue
        {
            get { return _maxValue; }
            set
            {
                _maxValue = value;
                RaisePropertyChanged("MaxValue");
                MajorTicks = MaxValue/10;
            }
        }

        public int MaxAmps
        {
            get { return _maxAmps; }
            set
            {
                _maxAmps = value;
                RaisePropertyChanged("MaxAmps");
            }
        }

        public double Speed
        {
            get { return _speed; }
            set
            {
                _speed = value;
                RaisePropertyChanged("Speed");
                RaisePropertyChanged("SpeedText");
            }
        }

        public double Alarm
        {
            get { return _alarm; }
            set
            {
                _alarm = value;
                RaisePropertyChanged("Alarm");
            }
        }

        public string Label
        {
            get { return _label; }
            set
            {
                _label = value;
                RaisePropertyChanged("Label");
            }
        }

        public string SpeedText
        {
            get
            {
                return string.Format("{0:0} km/h",Speed);
            }
            
        }

        public int MajorTicks
        {
            get { return _majorTicks; }
            set
            {
                _majorTicks = value;
                RaisePropertyChanged("MajorTicks");
            }
        }

        public double GaugeHeight
        {
            get { return _height; }
            set
            {
                _height = value;
                RaisePropertyChanged("Height");
            }
        }


        ////public override void Cleanup()
        ////{
        ////    // Clean own resources if needed

        ////    base.Cleanup();
        ////}
    }
}